package org.blade.personal.manager.sys.corncre;

import java.util.List;

import org.blade.personal.dao.sys.RoleDao;
import org.blade.personal.manager.sys.RoleManager;
import org.blade.personal.mode.sys.SystemRole;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 
 * @author zgf
 *
 */
@Transactional("transactionManager")
@Service("RoleManager")
public class RoleManagerImpl implements RoleManager{

	@Autowired
	private RoleDao roleDao;
	
	@Override
	public void save(SystemRole role) {
		roleDao.add(role);
	}


	@Override
	public void modify(SystemRole role) {
		roleDao.update(role);
	}
	
	@Override
	public List<SystemRole> fetchRoles() {

		return roleDao.fetchAllRoles();
	}
	

	@Override
	public int removeByIds(String ids) {
		String[] idArr = ids.split(",");
		
		int i = 0;
		for(String id : idArr){
			i += roleDao.delete(Long.parseLong(id));
		}
		return i;
	}
	
	@Override
	public SystemRole getById(Long id) {
		// TODO Auto-generated method stub
		return roleDao.queryOne(id);
	}

}
